/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.anism.API;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import org.anism.bean.EmployeeFacadeLocal;
import org.anism.business.Planning;
import org.anism.entity.Employee;

/**
 *
 * @author user
 */
@Stateless
public class HolidayPlanning implements HolidayPlanningLocal {
    
    @EJB
    private AuthenticationLocal authentication;
    
    @EJB
    private EmployeeFacadeLocal employeeFacade;

    @Override
    public Employee authenticate(final String employeeId, final String password) {
        return authentication.authenticate(employeeId, password);
    }

    /**
     * 
     * @param employee l'employé pour lequel récup le planning
     * @return le planning de l'employee
     */
    @Override
    public Planning getPlanning(final String employeeId) {
        Logger.getLogger(HolidayPlanning.class.getName()).log(Level.INFO, "HolidayPlanning :: Load planning for empId = {0}", employeeId);
        Employee employee = employeeFacade.getEmployeeForID(employeeId);
        Planning plan = new Planning(employee);
        Logger.getLogger(HolidayPlanning.class.getName()).log(Level.INFO, "HolidayPlanning :: Number of requests for employee({0}) : {1}", new Object[]{employeeId, plan.getRequestsToDisplay().size()});
        return plan;
    }
}
